class: center, middle, inverse, title-slide # Lecture 13 ## Models for Factorial Designs ### Psych 10 C ### University of California, Irvine ### 04/25/2022 --- ## Models for factorial designs - The previous class we talked about two different models for factorial designs. -- - The **Null** model which formalizes the assumption that the combinations of our factors (groups) have no effect on the expectation of our dependent variable (observations). -- - The Null model is expressed formally as: `$$y_{ijk}\sim\text{Normal}(\mu,\sigma_0^2)$$` - Where `\(i\)` represents the observation number of the combination of the *j-th* level of factor 1 and the *k-th* level of factor 2. -- - The second type of model we covered was the **Main effects** model. Main effects models assume that the expected value of our dependent variable is different between levels of a single factor regardless of the values of other factors on the experiment. -- - The number of Main effects models that we will have depends on the number of independent factors that we have. --- ## Models for factorial designs - As we saw last class, a Main effects model for factor `\(j\)` was expressed as: `$$y_{ijk}\sim\text{Normal}(\mu+\alpha_j,\sigma_1^2)$$` -- - While the main effects model of factor `\(k\)` is: `$$y_{ijk}\sim\text{Normal}(\mu+\beta_k,\sigma_2^2)$$` -- - We will only work with `\(2\times 2\)` factorial designs for now, so these are the only two main effects models that we need. -- - Remember that we use a different effects variable `\((\alpha_j\)` for factor `\(j\)` and `\(\beta_k\)` for factor `\(k\)`) because we will use those variables for another model. -- - Today, we will introduce the remaining two models that we use in a factorial design and work on an example using data from our anxiety example with different cohorts of students that took either a statistics course during the year or another class. --- ## The additive model - An additive model will formalize the assumption that two (or more depending on the number of independent variables) have an effect on the expected value of our dependent variable. Furthermore, this type of model assumes that those effects are independent and therefore can be added together in order to make a prediction. -- - We express an additive model formally as: `$$y_{ijk}\sim\text{Normal}(\mu+\alpha_j+\beta_k,\sigma_3^2)$$` -- - Where `\(\mu\)` is the grand mean, `\(\alpha\)` represents the main effect of factor 1 and `\(\beta\)` represents the main effect of factor 2. In this case, the factors are added in order to make a prediction. -- - This means that the model prediction for a participant that responds to a combination of the *j-th* level of factor one and the *k-th* level of factor 2 will be: `$$\mu_{jk} = \mu + \alpha_j + \beta_k$$` --- ## Example: anxiety by cohort and stats class - Problem: we want to study the effect of the cohort that student is in and whether they took a statistics class during their first year on the anxiety levels of students at a university. -- - We have a `\(2\times2\)` between subjects factorial design where the first factor is cohort (2019 `\(j=1\)` vs 2020 `\(j=2\)`) and the second factor is taking a statistics class `\((k=1)\)` vs taking any other class `\((k=2)\)`. -- - Then, the predicted anxiety level of any student in the 2019 cohort that took a statistics class would be:$$\hat{\mu} + \hat{\alpha}_1 + \hat{\beta}_1$$ -- - Where `\(\hat{\mu}\)` represents the estimator of the grand mean and `\(\hat{\alpha}_1\)` and `\(\hat{\beta}_1\)` represent the main effect of cohort and statistics class respectively. -- - The predicted anxiety level of any student in the 2020 cohort that took a statistics class would be: `$$\hat{\mu} + \hat{\alpha}_2 + \hat{\beta}_1$$` --- ## Visualizing the predictions of additive models - As we did with main effects models, we can also make a visual representation of the predictions of an additive model: -- .pull-left[ ```r plot(x = 0, y = 0, axes = FALSE, ann = FALSE, type = "n", xlim = c(0,1), ylim = c(0,1)) box(bty = "l") segments(x0 = c(0.1,0.1), y0 = c(0.1,0.6), x1 = c(0.9,0.9), y1 = c(0.4,0.9), col = c("#c80064","#54bebe"), lwd = 3) axis(side = 1, at = c(0.1,0.9), labels = c("2019", "2020"), cex.axis = 1.7) segments(x0 = 0.12, y0 = 0.5, x1 = 0.88, y1 = 0.5, col = "#555555", lwd = 2, lty = 2) mtext(text = "Anxiety level", side = 2, cex = 2, line = 0.5) legend("topleft", legend = c("No stats","Stats", "grand mean"), col = c("#c80064","#54bebe","#555555"), lwd = 2, cex = 1.4, bty = "n") ``` ] .pull-right[ <img src="data:image/png;base64,#lec-13_files/figure-html/add-pred-graph-out-1.png" style="display: block; margin: auto;" /> ] --- <img src="data:image/png;base64,#lec-13_files/figure-html/add-2-pred-graph-1.png" style="display: block; margin: auto;" />